IN-CORE / pyincore

pyIncore is a component of IN-CORE. It is a python package consisting of two primary components: 1) a set of service classes to interact with the IN-CORE web services, and 2) IN-CORE analyses . The pyIncore allows users to apply various hazards to infrastructure in selected areas, propagating the effect of physical infrastructure damage and loss of functionality to social and economic impacts.
Mozilla Public License 2.0
25 stars 7 forks source link

added guid field insertion method for geopackage file #479

Closed ywkim312 closed 9 months ago

ywkim312 commented 10 months ago

Test with the attached data.zip file. Unzip the file then there will be epn.shp, guid_no.gpkg, and landcover. gpkg Use the following snippet

from pyincore.utils.geoutil import GeoUtil

# test adding guid to shapefile
def add_guid_shapefile():
    infile = "C:\\rest\\test\\epn.shp"
    outfile = "C:\\rest\\test\\epn_guid.shp"
    GeoUtil.add_guid(infile, outfile)

# test adding guid to geopackage
def add_guid_geopackage():
    infile = "C:\\rest\\test\\guid_no.gpkg"
    outfile = "C:\\rest\\test\\guid_yes.gpkg"
    GeoUtil.add_guid(infile, outfile)

# test adding guid to geopackage
def add_guid_landcover_geopackage():
    infile = "C:\\rest\\test\\landcover.gpkg"
    outfile = "C:\\rest\\test\\landcover_yes.gpkg"
    GeoUtil.add_guid(infile, outfile)

if __name__ == "__main__":
    add_guid_shapefile()
    add_guid_geopackage()
    add_guid_landcover_geopackage()

add guid shapefile and add guid geopackage should work and generate output files but add guid landcover will make an error saying the the file contains the raster and it is not supported. Also please check the output files if they have guid field in it using QGIS or others. Please modify file path to you own. data.zip