import os
from qgis.core import QgsVectorLayer, QgsCoordinateReferenceSystem
import processing
from qgis.core import QgsProject, QgsPalLayerSettings, QgsVectorLayerSimpleLabeling
folder_path = "address"
for root, folders, files in os.walk(folder_path):
for file in files:
shpfile_path = os.path.join(root, file)
if shpfile_path.endswith('.shp'):
layer_name = os.path.splitext(file)[0]
vector_layer = QgsVectorLayer(shpfile_path, layer_name, 'ogr')
reprojected_layer = processing.run("native:reprojectlayer",
{ 'TARGET_CRS': 'EPSG:5181',
'INPUT': vector_layer, 'OUTPUT': f"memory:{file}"})['OUTPUT']
QgsProject.instance().addMapLayer(reprojected_layer)
layers = QgsProject.instance().mapLayers()
for layer_id, layer in layers.items():
if 'Ele' in layer.name():
ele_layer = layer
elif 'Con' in layer.name():
con_layer = layer
else:
sejong_layer = layer
ele_clip = processing.run("native:clip",{ 'INPUT' : ele_layer,
'OUTPUT' : 'TEMPORARY_OUTPUT',
'OVERLAY' : sejong_layer})['OUTPUT']
buffer_distance= QInputDialog.getInt(None,'buffer',"Give it to me")[0]
buffered_ele = processing.run("native:buffer",
{'INPUT': ele_clip, 'DISTANCE': buffer_distance, 'SEGMENTS': 5,
'END_CAP_STYLE': 0, 'JOIN_STYLE': 0, 'MITER_LIMIT': 2,
'DISSOLVE': False, 'OUTPUT': 'memory:'})['OUTPUT']
con_in_ele = processing.run("native:countpointsinpolygon", {
'CLASSFIELD': '',
'FIELD': 'NUMPOINTS',
'OUTPUT': 'TEMPORARY_OUTPUT',
'POINTS': con_layer,
'POLYGONS': buffered_ele,
'WEIGHT': ''})['OUTPUT']
QgsProject.instance().addMapLayer(con_in_ele)
grid_size=QInputDialog.getInt(None,'grid',"Give it to me")[0]
grid_sq = processing.run('native:creategrid', {
'CRS': QgsProject.instance().crs(),
'EXTENT': sejong_layer,
'HOVERLAY': 0,
'HSPACING': grid_size,
'VSPACING': grid_size,
'TYPE': 4,
'VOVERLAY': 0,
'OUTPUT': 'TEMPORARY_OUTPUT'
})['OUTPUT']
grid_sejong = processing.run("native:extractbylocation", {
'INPUT': grid_sq,
'INTERSECT': sejong_layer,
'OUTPUT': 'TEMPORARY_OUTPUT',
'PREDICATE': [0]
})['OUTPUT']
con_in_sejong = processing.run("native:countpointsinpolygon", {
'CLASSFIELD': '',
'FIELD': 'NUMPOINTS',
'OUTPUT': 'TEMPORARY_OUTPUT',
'POINTS': con_layer,
'POLYGONS': grid_sejong,
'WEIGHT': ''})['OUTPUT']
QgsProject.instance().addMapLayer(con_in_sejong)
This code is only for my test.
This code is correct?
Korean hiphop Cheer up.
I’ll delete this script as soon as possble.
It has speciality.
Ok bye
I really appreciate you.
It’s still Dre Day nigga, AK nigga
Though I’ve grown a lot, can’t keep it home a lot
‘Cause when I frequent the spots that I’m known to rock
You hear the bass from the truck when I’m on the block
Ladies they pay homage, but haters say Dre fell off
How nigga? My last album was The Chronic (Nigga)
They want to know if he still got it
They say rap’s changed
They wanna know how I feel about it
(If you ain’t up on thangs)
Dr. Dre is the name
I’m ahead of my game
Still puffing my leafs
Still fuck with the beats, still not loving police
Still rock my khakis with a cuff and a crease
Still got love for the streets, reppin’ 213 (For life)
Still the beats bang, still doing my thang
Since I left ain’t too much changed, still
I’m representing for them gangstas all across the world
(Still) Hitting them corners in them low-lows, girl
Still taking my time to perfect the beat
And I still got love for the streets, it’s the D-R-E
I’m representing for them gangstas all across the world
(Still) Hitting them corners in them low-lows, girl
Still taking my time to perfect the beat
And I still got love for the streets, it’s the D-R-E
Since the last time you heard from me, I lost some friends
Well, hell, me and Snoop, we dippin’ again
Kept my ear to the streets, signed Eminem
He’s triple platinum, doing 50 a week
Still, I stay close to the heat
And even when I was close to defeat, I rose to my feet
My life’s like a soundtrack I wrote to the beat
Treat rap like Cali’ weed, I smoke ’til I sleep
Wake up in the a.m., compose a beat
I bring the fire ’til you’re soaking in your seat
It’s not a fluke, it’s been tried, I’m the truth
Since “Turn Out the Lights” from the World Class Wreckin Cru
I’m still at it, after-mathematics
In the home of drive-bys and ak-matics
Swap meets, sticky green, and bad traffic
I dip through, then I give you (Still) D-R-E
강상우 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.