Closed harshmistry96 closed 2 years ago
Link to Geotiff: https://sedac.ciesin.columbia.edu/downloads/data/gpw-v4/gpw-v4-population-density-rev11/gpw-v4-population-density-rev11_2020_2pt5_min_tif.zip
Cannot download that. It requires a sign in. I'd like to check the image CRS, if there is one, and try warp it. Here is an example:
import cartopy.crs as ccrs
from cartopy.img_transform import warp_array
source_extent = [lon.min(), lon.max(), lat.min(), lat.max()]
new_data = warp_array(
colored_data,
target_proj=ccrs.GOOGLE_MERCATOR,
source_proj=ccrs.PlateCarree(), # change here for the source projection you have
target_res=data.shape,
source_extent=source_extent,
target_extent=None,
mask_extrapolated=False,
)
m = folium.Map(location=[lat.mean(), lon.mean()], zoom_start=1)
folium.raster_layers.ImageOverlay(
image=new_data[0],
bounds=[[lat.min(), lon.min()], [lat.max(), lon.max()]],
opacity=0.25,
).add_to(m)
Here is the file: The crs for geotiff is epsg 3857. Please let me know your thoughts.
Can't promise but I'll play with it and see if I can make it work. I'll report back if successful.
You can, and you should probably do it, with warp_array
like in my example above. However, this image was quite big for me to handle on my laptop so I used the sub-sampled cartopy image instead (it is virtually the same thing b/c cartopy is using warp_array under the hood). I went that route just to be sure I had the proper metadata.
https://nbviewer.org/gist/ocefpaf/5e570a1b11d51a9f65eae8592290f4c2
BTW, closing this b/c it is now a folium problem but data handling.
I am trying to overlay a GeoTiff image on folium map but I think there is an alignment issue. Already tried with mercator_project=True, but still there is an alignment issue.
Link to Geotiff: https://sedac.ciesin.columbia.edu/downloads/data/gpw-v4/gpw-v4-population-density-rev11/gpw-v4-population-density-rev11_2020_2pt5_min_tif.zip
Code is as follow:
Result is as follow: