I have a shapefile, made up of many individual polygons that are essentially arranged in a pixel structure (this file: https://data.gov.uk/dataset/vessel-density-grid-2014). I am interested in the Annual_Ave field data.
I also have a regular array of points that I wish to interpolate against this data. The problem that I have is that the vector data is at a different angle to my array of points (my points are parallel to lines of constant latitude and longitude). The first image roughly illustrates what I mean, the second image is a close up of the actual data to illustrate the problem. I want to be able to perform this interpolation in Python, using GDAL/OGR, and am happy to store the vector data in a different format to facilitate this.
I tried converting the vector polygon layer to a raster, using the ArcGIS polygon to raster function, in the hope that I could extract the latitude and longitude points of each pixel and use this to interpolate my own data. However, when I import the resulting raster into Python using GDAL, the rotational information does not seem to be present so the geotransform is incorrect.
Example (raster file created with ArcGIS Polygon to raster, Cell Size=0.004):
import gdal in_ds = gdal.Open(<path to raster file>) in_ds.GetGeoTransform() Out: (-10.036726874521381, 0.004, 0.0, 63.932379486900615, 0.0, -0.003999999999999999)
As you can see, the rotation field is 0 even though the polygons are clearly rotated as can be seen in the file. This means that the latitude and longitude values that can be generated from the geotransform data do not match up with those for the pixels in the file.
The other thing that I considered was loading all of the polygons into Python, getting the latitude and longitudes of all the points from the polygon centres, ordering them and interpolating my data points against this. The issue I think with this is that it will be pretty slow, as it is a large vector dataset containing some 280,000 polygons.
Ideally, I think that it would be preferable to save the vector layer as a rotated, interpolated raster as it is essentially raster data that they have stored as a vector for convenience.