-1

I am computing geographical densities by using MySQL polynomials to create a grid over a specific location in the world. I use geospatial indices on the grid in order to improve speed when I run the MySQL st_contains command. It all works great but it very slow since I use a resolution of 1/1000 of a degree. Below is a plot using Google Maps API polyline to draw the grids and the coloring the grids based on the count found using st_contains. Since I need to do the entire world, I need to switch to less resolution for my grid.

I have tried the following Python plotting routines: pcolormesh, imshow, heatmap, scatter, and contourf. I have looked at also interpolating using Pythons griddata. I have not found something equivalent to plotting the polylines in Google Maps. Any recommendations?

Google Maps API results Python Contourf

tablewski
  • 59
  • 5

1 Answers1

0

My solution was to create "density maps" using matplotlib's imshow in python and saving the image as a png. The most difficult part was discovering that there was extra white space around the png image. Thanks to a user on stackoverflow.com Matplotlib plots: removing axis, legends and white spaces I was able to remove extra white space using and to fix the origin since my figure was rotated.

fig = mat.imshow(Zm,origin="lower",cmap='jet') 
mat.axis('off')
fig.axes.get_xaxis().set_visible(False)
fig.axes.get_yaxis().set_visible(False)
mat.savefig('test_border.png', bbox_inches='tight', pad_inches = 0,edgecolor='none',transparent=True,dpi=DPI_OUTPUT)

To georectify the image and create my tiles I used information found at https://developers.google.com/kml/articles/raster?hl=en

gdalinfo test_border.png
gdal_translate -of GTiff -a_srs EPSG:4326 -a_ullr 43.0 12  44.0 11 test_border.png test_border.tif
gdalwarp -s_srs EPSG:4326 -t_srs EPSG:4326 test_border.tif test_border_2.tif
gdal2tiles.py -t title -g MYLICENSE -p mercator -k  test_border_2.tif test_border

Now, I just need to run it for the remaining non-land sections of the world...

Community
  • 1
  • 1
tablewski
  • 59
  • 5