Intersection of points and polygons
How do I add a strong "onion flavor" to the biryani (in restaurant style)?
80-bit collision resistence because of 80-bit x87 registers?
Have the UK Conservatives lost the working majority and if so, what does this mean?
Why is Bernie Sanders maximum accepted donation on actblue $5600?
In the Lost in Space intro why was Dr. Smith actor listed as a special guest star?
Integral problem. Unsure of the approach.
Why are "square law" devices important?
Multiple null checks in Java 8
What's the function of the word "ли" in the following contexts?
Have any astronauts or cosmonauts died in space?
What is formjacking?
How many copper coins fit inside a cubic foot?
What does it mean when an external ID field follows a DML Statement?
What is the reason behind this musical reference to Pinocchio in the Close Encounters main theme?
How does holding onto an active but un-used credit card affect your ability to get a loan?
Boss asked me to sign a resignation paper without a date on it along with my new contract
For the Circle of Spores druid's Halo of Spores feature, is your reaction used regardless of whether the other creature succeeds on the saving throw?
SQL Server 2017 crashes when backing up because filepath is wrong
3D buried view in Tikz
Reduce Reflections
Draw triangle with text in vertices/edges
Minimum energy path of a potential energy surface
Why do we interpret the accelerated expansion of the universe as the proof for the existence of dark energy?
How do I write a maintainable, fast, compile-time bit-mask in C++?
Intersection of points and polygons
I have the code down, I wanted to intersect the points and polygons and to create a new shp (points) with polygon ID information.
It is replacing me at shp points and the table comes empty.
Attention was added a counter to see the progress of the process
#!/usr/bin/env python
-- coding: utf-8 --
try:
import os
import sys
import shutil
from shapely.geometry import shape, mapping
import fiona
except ImportError,err:
print "import error"
def main():
if len(sys.argv) == 1:
print "ERRO: Verifique a existencia da shapefile"
return 1
shppoints = sys.argv[1]
shpareas = sys.argv[2]
shppointsout = sys.argv[2]
isprj = False
with fiona.open(shppoints) as input1:
with fiona.open(shpareas) as input2:
with fiona.open(shppointsout, 'w', driver=input1.driver, crs=input1.crs, schema=input1.schema) as output:
n = 0
for feature1 in input1:
n += 1
isintersect = False
for feature2 in input2:
geom1 = shape(feature1['geometry'])
geom2 = shape(feature2['geometry'])
if geom1.intersects(geom2):
isintersect = True
feature1['properties']['ID_BUILD'] = feature2['properties']['ID']
output.write({'properties': feature1['properties'], 'geometry': mapping(geom1)})
isprj = True
break
if isintersect:
print "...intersect ID: "+str(feature1['properties']['ID'])+" TRUE! "+str(n)+"/"+str(len(input1))
else:
print "...intersect ID: "+str(feature1['properties']['ID'])+" FALSE! "+str(n)+"/"+str(len(input1))
prjfile = os.path.splitext(shppoints)[0]+".prj"
prjfileout = os.path.splitext(shppointsout)[0]+".prj"
if isprj and os.path.exists(prjfile):
shutil.copy(prjfile, prjfileout)
print "nDone!n"
if name == "main":
'''
shppoints = r"D:workAveiro_pontos.shp"
shppointsout = r"D:workAveiro_pontos_intersect.shp"
shpareas = r"D:workAveiro_parc.shp"
sys.argv.extend([shppoints, shpareas, shppointsout])
'''
main()
python intersection fiona
add a comment |
I have the code down, I wanted to intersect the points and polygons and to create a new shp (points) with polygon ID information.
It is replacing me at shp points and the table comes empty.
Attention was added a counter to see the progress of the process
#!/usr/bin/env python
-- coding: utf-8 --
try:
import os
import sys
import shutil
from shapely.geometry import shape, mapping
import fiona
except ImportError,err:
print "import error"
def main():
if len(sys.argv) == 1:
print "ERRO: Verifique a existencia da shapefile"
return 1
shppoints = sys.argv[1]
shpareas = sys.argv[2]
shppointsout = sys.argv[2]
isprj = False
with fiona.open(shppoints) as input1:
with fiona.open(shpareas) as input2:
with fiona.open(shppointsout, 'w', driver=input1.driver, crs=input1.crs, schema=input1.schema) as output:
n = 0
for feature1 in input1:
n += 1
isintersect = False
for feature2 in input2:
geom1 = shape(feature1['geometry'])
geom2 = shape(feature2['geometry'])
if geom1.intersects(geom2):
isintersect = True
feature1['properties']['ID_BUILD'] = feature2['properties']['ID']
output.write({'properties': feature1['properties'], 'geometry': mapping(geom1)})
isprj = True
break
if isintersect:
print "...intersect ID: "+str(feature1['properties']['ID'])+" TRUE! "+str(n)+"/"+str(len(input1))
else:
print "...intersect ID: "+str(feature1['properties']['ID'])+" FALSE! "+str(n)+"/"+str(len(input1))
prjfile = os.path.splitext(shppoints)[0]+".prj"
prjfileout = os.path.splitext(shppointsout)[0]+".prj"
if isprj and os.path.exists(prjfile):
shutil.copy(prjfile, prjfileout)
print "nDone!n"
if name == "main":
'''
shppoints = r"D:workAveiro_pontos.shp"
shppointsout = r"D:workAveiro_pontos_intersect.shp"
shpareas = r"D:workAveiro_parc.shp"
sys.argv.extend([shppoints, shpareas, shppointsout])
'''
main()
python intersection fiona
add a comment |
I have the code down, I wanted to intersect the points and polygons and to create a new shp (points) with polygon ID information.
It is replacing me at shp points and the table comes empty.
Attention was added a counter to see the progress of the process
#!/usr/bin/env python
-- coding: utf-8 --
try:
import os
import sys
import shutil
from shapely.geometry import shape, mapping
import fiona
except ImportError,err:
print "import error"
def main():
if len(sys.argv) == 1:
print "ERRO: Verifique a existencia da shapefile"
return 1
shppoints = sys.argv[1]
shpareas = sys.argv[2]
shppointsout = sys.argv[2]
isprj = False
with fiona.open(shppoints) as input1:
with fiona.open(shpareas) as input2:
with fiona.open(shppointsout, 'w', driver=input1.driver, crs=input1.crs, schema=input1.schema) as output:
n = 0
for feature1 in input1:
n += 1
isintersect = False
for feature2 in input2:
geom1 = shape(feature1['geometry'])
geom2 = shape(feature2['geometry'])
if geom1.intersects(geom2):
isintersect = True
feature1['properties']['ID_BUILD'] = feature2['properties']['ID']
output.write({'properties': feature1['properties'], 'geometry': mapping(geom1)})
isprj = True
break
if isintersect:
print "...intersect ID: "+str(feature1['properties']['ID'])+" TRUE! "+str(n)+"/"+str(len(input1))
else:
print "...intersect ID: "+str(feature1['properties']['ID'])+" FALSE! "+str(n)+"/"+str(len(input1))
prjfile = os.path.splitext(shppoints)[0]+".prj"
prjfileout = os.path.splitext(shppointsout)[0]+".prj"
if isprj and os.path.exists(prjfile):
shutil.copy(prjfile, prjfileout)
print "nDone!n"
if name == "main":
'''
shppoints = r"D:workAveiro_pontos.shp"
shppointsout = r"D:workAveiro_pontos_intersect.shp"
shpareas = r"D:workAveiro_parc.shp"
sys.argv.extend([shppoints, shpareas, shppointsout])
'''
main()
python intersection fiona
I have the code down, I wanted to intersect the points and polygons and to create a new shp (points) with polygon ID information.
It is replacing me at shp points and the table comes empty.
Attention was added a counter to see the progress of the process
#!/usr/bin/env python
-- coding: utf-8 --
try:
import os
import sys
import shutil
from shapely.geometry import shape, mapping
import fiona
except ImportError,err:
print "import error"
def main():
if len(sys.argv) == 1:
print "ERRO: Verifique a existencia da shapefile"
return 1
shppoints = sys.argv[1]
shpareas = sys.argv[2]
shppointsout = sys.argv[2]
isprj = False
with fiona.open(shppoints) as input1:
with fiona.open(shpareas) as input2:
with fiona.open(shppointsout, 'w', driver=input1.driver, crs=input1.crs, schema=input1.schema) as output:
n = 0
for feature1 in input1:
n += 1
isintersect = False
for feature2 in input2:
geom1 = shape(feature1['geometry'])
geom2 = shape(feature2['geometry'])
if geom1.intersects(geom2):
isintersect = True
feature1['properties']['ID_BUILD'] = feature2['properties']['ID']
output.write({'properties': feature1['properties'], 'geometry': mapping(geom1)})
isprj = True
break
if isintersect:
print "...intersect ID: "+str(feature1['properties']['ID'])+" TRUE! "+str(n)+"/"+str(len(input1))
else:
print "...intersect ID: "+str(feature1['properties']['ID'])+" FALSE! "+str(n)+"/"+str(len(input1))
prjfile = os.path.splitext(shppoints)[0]+".prj"
prjfileout = os.path.splitext(shppointsout)[0]+".prj"
if isprj and os.path.exists(prjfile):
shutil.copy(prjfile, prjfileout)
print "nDone!n"
if name == "main":
'''
shppoints = r"D:workAveiro_pontos.shp"
shppointsout = r"D:workAveiro_pontos_intersect.shp"
shpareas = r"D:workAveiro_parc.shp"
sys.argv.extend([shppoints, shpareas, shppointsout])
'''
main()
python intersection fiona
python intersection fiona
asked 2 mins ago
Endi SoaresEndi Soares
193
193
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313193%2fintersection-of-points-and-polygons%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313193%2fintersection-of-points-and-polygons%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown