Skip to content

Commit

Permalink
encode and fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoray committed Dec 27, 2023
1 parent dca2336 commit c83b4cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions encode_shapefile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To be run in QGIS Python Console
in_shp = r'/path/in_shapefile.shp'
out_shp = r'/path/out_shapefile.shp'

options = f'-lco ENCODING=Shift_JIS'

processing.run("gdal:convertformat",
{'INPUT':in_shp,
'CONVERT_ALL_LAYERS':False,
'OPTIONS':options,
'OUTPUT':out_shp})

12 changes: 12 additions & 0 deletions get_layer_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To be run in QGIS Python Console
target_layer_name = 'some_layer'

# Find the target layer by name
target_layer = QgsProject.instance().mapLayersByName(target_layer_name)[0]

# Check if the layer was found and is valid
if target_layer:
# Get the list of fields
fields = target_layer.fields()
for field in fields:
print(field.name())

0 comments on commit c83b4cf

Please sign in to comment.