I'm writing some python to create grid lines, either as a series of densified LINESTRINGs or a set of MULTIPOINTs.
The code uses shapely, and I'm writing WKT to a CSV and importing into QGIS(2.18.3) as a delimited file. I'm running this in a python venv with the following (output from pip freeze)
Fiona==1.7.5
Pillow==4.1.0
Shapely==1.5.17
click==6.7
click-plugins==1.0.3
cligj==0.4.0
munch==2.1.1
numpy==1.12.1
olefile==0.44
psycopg2==2.7.1
pyproj==1.9.5.1
six==1.10.0
The code is as follows:-
from shapely.geometry import MultiPoint, LineString
def graticule(long_degrees=10, lat_degrees=10, segments=1000,
geometry_type=MultiPoint):
"""
Generator. Emits a series of geometries
:param long_degrees: separation of longitude
:param lat_degrees: seperate of latitude
:param segments: number of segments (bigger values = smoother)
:param geometry_type: type of geom (MultiPoint, Linestring)
:return: yields shapes. Up to client to iterate over these
"""
# meridians
for long in range(-180,180,long_degrees):
coords = []
longitude = float(long)
for lat_step in range(0, segments):
latitude = float(90.0-(lat_step*(180.0/segments)))
coords.append((longitude, latitude))
yield geometry_type(coords)
# latitudes
for lat in range(-90,90,lat_degrees):
coords = []
latitude = float(lat)
for long_step in range(0, segments):
longitude = float(-180.0+(long_step*(360.0/segments)))
coords.append((longitude, latitude))
yield geometry_type(coords)
def main():
"""
Makes a 10 degree grid as a WKT CSV file
:return:
"""
with open("/tmp/foo.csv","w") as output_file:
output_file.write("GEOM\n")
for geom in graticule(10,10,1000,MultiPoint):
output_file.write("{}\n".format(geom.wkt))
print("Finished!")
if __name__ == "__main__":
main()
It works flawlessly when I choose LineString as the geometry_type...
but when I choose Multipoint, I only see things to the east of the Prime Meridian. And the lines of latitude disappear completely.
Does anyone have any clue what's going on here? I've shown using the Bonne projection, but it also happens with plain old wgs84. I've also tried sorting the multipoints so that they go north to south, but the result is the same :/
No errors were thrown.