def view_CoRegPoints_folium(self, attribute2plot='ABS_SHIFT', cmap=None, exclude_fillVals=True): warnings.warn( UserWarning( 'This function is still under construction and may not work as expected!' )) assert self.CoRegPoints_table is not None, 'Calculate tie point grid first!' import folium import geojson from folium.raster_layers import ImageOverlay lon_min, lat_min, lon_max, lat_max = \ reproject_shapelyGeometry(self.im2shift.box.mapPoly, self.im2shift.projection, 4326).bounds center_lon, center_lat = (lon_min + lon_max) / 2, (lat_min + lat_max) / 2 # get image to plot image2plot = self.im2shift[:, :, 0] # FIXME hardcoded band from py_tools_ds.geo.raster.reproject import warp_ndarray image2plot, gt, prj = \ warp_ndarray(image2plot, self.im2shift.geotransform, self.im2shift.projection, in_nodata=self.nodata[1], out_nodata=self.nodata[1], out_XYdims=(1000, 1000), q=True, out_prj='epsg:3857') # image must be transformed into web mercator projection # create map map_osm = folium.Map(location=[center_lat, center_lon]) # ,zoom_start=3) # import matplotlib ImageOverlay( colormap=lambda x: (1, 0, 0, x), # TODO a colormap must be given # colormap=matplotlib.cm.gray, # does not work image=image2plot, bounds=[[lat_min, lon_min], [lat_max, lon_max]], ).add_to(map_osm) points_values = self.CoRegPoints_table[['geometry', attribute2plot]] points_values.geometry.crs = points_values.crs folium.GeoJson(points_values).add_to(map_osm) # add overlap polygon overlapPoly = reproject_shapelyGeometry(self.COREG_obj.overlap_poly, self.im2shift.epsg, 4326) gjs = geojson.Feature(geometry=overlapPoly, properties={}) folium.GeoJson(gjs).add_to(map_osm) return map_osm
def _compute_tie_points(self): CRL = COREG_LOCAL(self.cfg.path_reference_image, self._EnMAP_band, grid_res=40, max_shift=5, nodata=(self._ref_Im.nodata, 0), footprint_poly_tgt=reproject_shapelyGeometry( self._EnMAP_Im.meta.vnir.ll_mapPoly, 4326, self._EnMAP_band.epsg), mask_baddata_tgt=self._EnMAP_mask) TPG = CRL.tiepoint_grid # CRL.view_CoRegPoints(shapes2plot='vectors', hide_filtered=False, figsize=(20, 20), # savefigPath='/home/gfz-fe/scheffler/temp/EnPT/Archachon_AROSICS_tiepoints.png') valid_tiepoints = TPG.CoRegPoints_table[ TPG.CoRegPoints_table.OUTLIER.__eq__(False)].copy() return valid_tiepoints
def _validate_input(self): # check geocoding of DEM if not self.dem.is_map_geo: raise ValueError(( self.dem.gt, self.dem.prj ), 'The provided digital elevation model has no valid geo-coding or projection.' ) # check if provided as WGS-84 ell = CRS(self.dem.prj).datum.ellipsoid.name if ell != 'WGS 84': raise ValueError( ell, "The digital elevation model must be provided with 'WGS84' as geographic datum." ) # check overlap dem_ll_mapPoly = reproject_shapelyGeometry(self.dem.footprint_poly, prj_src=self.dem.epsg, prj_tgt=4326) enmapIm_ll_mapPoly = get_footprint_polygon(self.enmapIm_cornerCoords, fix_invalid=True) overlap_dict = get_overlap_polygon(dem_ll_mapPoly, enmapIm_ll_mapPoly) overlap_perc = round(overlap_dict['overlap percentage'], 4) if overlap_perc < 100: # compute minimal extent in user provided projection cornersXY = np.array([ transform_any_prj(4326, self.dem.epsg, x, y) for x, y in self.enmapIm_cornerCoords ]) xmin, xmax = cornersXY[:, 0].min(), cornersXY[:, 0].max() ymin, ymax = cornersXY[:, 1].min(), cornersXY[:, 1].max() raise ValueError( 'The provided digital elevation model does not cover the EnMAP image completely ' '(only around %.1f percent). The minimal needed extent in the provided projection is: \n' 'xmin: %s, xmax: %s, ymin: %s, ymax: %s.' % (overlap_perc, xmin, xmax, ymin, ymax))