resolution = 10 plane = False # on curve w = rdggs.cell_width(resolution) if plane: area = w**2 else: area = 8 / (3 * math.pi) * w**2 # change to metres with one decimal place w = (" %2.0f m" % (w)) # print () # calculate the dggs cell from long and lat ie t thisCell = rdggs.cell_from_point( resolution, t, plane=False) # false = on the curve dggsCell = str(thisCell) #find the boundary for exporting into ESRI or GDAL dggsLoc = list() # empty list ready to fill for item in dggsCell: # build a dggs location cell as a list like dggsLoc = ['R', 7, 2, 4, 5, 6, 3, 2, 3, 4, 3, 8, 3] if item.isalpha(): # the letter 'R' at the beginning dggsLoc.append(item) else: item = int(item) # the numbers in the cell dggsLoc.append(item) c = rdggs.cell(dggsLoc) # print (c) bound = list() # put in try statement for Tasmanian ones that produce an error?
print('crs', testfile.crs) # the coordinate reference system print('attributes', testfile.all_attributes) # retrieves the combined set of all feature attributes print('common attributes', testfile.common_attributes) # retrieves only those field attributes that are common to all features print() # make an output file of DGGS centroid points with the at atttibute properties newfile = pygeoj.new() # default projection is WGS84 #work through the features (polygons) one by one and ask for DGGS cells for feature in testfile: print('feature attributes ', feature.properties) # the feature attributes - want to keep for output coords = feature.geometry.coordinates # xy print('geom', coords) this_dggs_cell = rdggs.cell_from_point(resolution, coords, plane=False) # false = on the elipsoidal curve print('found cell = ', this_dggs_cell) my_prop = feature.properties my_Cell = {"AusPIX_DGGS": str(this_dggs_cell), "LongiWGS84": coords[0], "LatiWGS84": coords[1], "CellArea_M2": resArea} #include the AusPIX cell information in attributes these_attributes = dict(list(my_Cell.items()) + list(my_prop.items())) #print('these attributes = ', these_attributes) newfile.add_feature(properties=these_attributes, geometry={"type": "Point", "coordinates": coords}) #save the ouput geojson file newfile.save("test_points.geojson") # saves into the folder where you have the script - edit to change