0
votes

I'm new to GIS, I've been working with maps plotting points with Latitude, Longitude coordinates over a map. I would like to build a spatial 500 m square grid over a map, to later intersect the points with this new spatial constraint. The output should be in .shp file.

So far I've been using the basemap package to read easily and plotting some already made grids in the form:

Code minx miny maxx maxy

stating for each square (Code), the coordinates of its vertices. I can't figured out how to make a new grid, given a selected space region as:

# Projection CYL Cylindrical Equal Distance Projections (PlateCarree)
m = Basemap(projection='cyl',
    llcrnrlat=41.1905,urcrnrlat=41.5404,
    llcrnrlon=1.9144,urcrnrlon=2.6628,
    resolution='c')

Any help would be appreciated.

1

1 Answers

2
votes

Finally I've managed all the things with Geopandas and Basemap. First of all I found a script to divide the portion of space (in UTM Zone 31 projection), into an equally space grid of 500 m. Then I had to convert the grid coordinates to Lat/Lon, in order to fit it with my points:

import geopandas as gpd

geofile_in = 'UTMgrid.shp'
geofile_out = 'LATLONgrid.shp'

g = gpd.read_file(geofile_in)

originalcrs = {u'units': u'm', u'ellps': u'WGS84', u'datum': u'WGS84', u'proj': u'utm', u'zone': 31}
targetcrs = {u'ellps': u'WGS84', u'datum': u'WGS84', u'proj': u'longlat'}

# Set the original crs (UTM Zone 31 N)
g.crs = originalcrs
# Transform the Grid to the target crs (Lon, Lat)
g.to_crs(crs=targetcrs, inplace=True)
# Save to .shp file
g.to_file(geofile_out)

Hope that helps.