At my work, I need to convert different kinds of files into Geotiff files. Now I have to convert a banch o KML files. Those came with the coordinates from the corners of the polygon. Using rasterio to convert to GeoTiff, I need to use West, East, South and North coordinates, which is giving me a couple of meters of error from the rigth location. Any advice? My code and the image on Google Earth:
How the coordinates come on KML file:
[['POLYGON ((-68.02573239434068 10.458541609679036'], [' -67.97139569083748 10.447019877002532'], [' -67.9631296429911 10.495261426980813'], [' -68.01557210143345 10.506382845074937'], [' -68.02573239434068 10.458541609679036))']
Code:
south = np.float64(lat_min)
north = np.float64(lat_max)
east = np.float64(lon_min)
west = np.float64(lon_max)
with rio.open(png, 'r') as img:
img = img.read([1])
img = img.astype('uint16')
bounds = rio.transform.from_bounds(west, south, east, north,
img.shape[1],
img.shape[2])
crs = '+proj=latlong'
show(img) #shows true color
with rio.open('{}.tiff'.format(file),'w',
driver='GTiff',
count=1,
height=img.shape[1],
width=img.shape[2],
dtype=img.dtype,
crs=crs,
transform= bounds,
) as dst:
dst.write(img)