Related to When are field calculator scripting questions on topic? and various comments on that Meta question (and many Main questions since) I think it is clear that we do not have consensus on where the line should be drawn between pure Python (better researched/asked at Stack Overflow) and Python functionality that is core to modern GIS (on-topic for here).

Where would you draw that line?


Another excellent example of why defining the line for 'pure' Python questions is going to be difficult: Using variable in SelectByAttribute_management.

At the lowest level possible, it is purely a Python syntax issue.

However, the error given would indicate an error outside of Python, within the ArcGIS API:

Runtime error Traceback (most recent call last): File "", line 1, in File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 6435, in SelectLayerByAttribute raise e ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).

If you look up this error message you'll find:

The SQL expression is invalid.

It takes knowledge of both ArcGIS and Python to understand what the problem is and what the solution should be.

Now, the question is, should I answer this? It's actually fairly simple, and I've already spent more time creating this answer than it would have taken to do that.
I could also vote to close it as off-topic. But, given the fact that I've already taken the time to read and understand the question, and I know a solution, am I really improving this community by voting to close this question?

At the very least, I believe trying to define what is 'pure' Python is going to be a moving target, and something this community will struggle with on an on-going basis.

  • @PolyGeo Agreed. The self answer either wasn't posted when I was looking at that question, or I simply didn't see it when I saw it in the review queue...if I had, I would have suggested the same. Nov 17 '15 at 23:45
  • 1
    @PolyGeo I'm not questioning that it's a duplicate, and should be closed for that reason. I brought it up as an example of a question that should be considered 'pure Python,' and to illustrate how fuzzy that line between Python and GIS will be...this question is entitled 'Where is the line between Python and GIS?' is it not? Dec 13 '15 at 23:38
  • @PolyGeo When I said 'should be considered', it really should have been 'could be considered.' To answer your question, no I wouldn't have voted to close it as off topic. This particular question deals with string formatting, which you can find tons of questions about on SO. My point is: if a question could be on Stack Overflow in a more general format, does that mean it should be off topic here? I don't think we can be that general. Dec 15 '15 at 12:50
  • Any spatial Python library question could be on Stack Overflow but I consider them more on-topic here. Any Python library question without a spatial component is off-topic here but on-topic there.
    – PolyGeo Mod
    Dec 15 '15 at 13:15

I'll provide an answer based on an example question that has since been deleted by the Community user: https://gis.stackexchange.com/questions/167074/using-a-text-file-to-create-shapefile-with-attributes.

It was:

I'm using this with Python and Arcpy

Before I begin to code, I was wondering if it was possible to take a .txt file, and extract the first line as the field values, and extract the next lines of coordinates as extents.

An exmaple of the .txt file is like this:

1867-Jan-01 Field value  Field Value  Field Value Field Value  Field Value
  52N  62W
  42N  52W
  32N  42W
  22N  32W
  12N  22W
  11N  12W
  10N  13W

I would have a shapefile already created and all I would need to do is create the polygon files using the coordinates and populate the attribute table with values above it.

Is this a possibility using Python and Arcpy, and what direction should I take it?

This question from Main contains two questions. The second question (creating geometries using ArcPy) is clearly on-topic (but probably a duplicate) while the first question is about how to read lines from a text file using Python.

I voted to put the question on hold because the asker had not included a code snippet to show what they had tried and where they were stuck. However, if they had included a code snippet and that was about how to read lines from a text file using Python, rather than the geometry part, then I would still have voted to put it on hold as being better researched/asked at Stack Overflow.

If the question ceases to be about how to read lines from a text file using Python and becomes only about creating geometries using ArcPy then I will consider it to be highly on-topic for GIS SE and be ready to provide an answer or cite a duplicate.

  • 3
    This example raises an important aspect too. We have quite a few good python coders here. We do not have all that many super amazing all-world "Wow! I didn't know you could to that!" python coders hanging out here. We have a few of those, but SO is really the place to find them, and that is the main reason to move pure python questions over to SO. Dec 17 '15 at 14:50
  • @blord-Castillo I could not agree more. I think encouraging aspiring spatial programmers to only look for and ask for non-spatial Python help here, instead of finding it instantly at Stack Overflow is certainly hindering them in the medium to long-term, and often in the short-term too.
    – PolyGeo Mod
    Feb 18 '20 at 1:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .