Jason Camerano<\/A> gaf me deze python snippet:<\/P>head, <\/SPAN>sep<\/SPAN>, <\/SPAN>tail = arcpy.Describe(parcelFabricLayer).Path.partition(".gdb"<\/SPAN>)workspacePath = head + sep<\/SPAN><\/PRE>uitleg:<\/P>Describe().Path retourneert het volledige pad dat ook de string ".gdb" bevat<\/P>partition scheidt dit met behulp van de opgegeven ".gdb" <\/SPAN>string om:<\/P>head - vóór de ".gdb" string<\/SPAN><\/LI>sep - de ".gdb" string<\/SPAN><\/LI>tail - na de ".gdb" string<\/SPAN><\/LI><\/UL><\/P>Iemand een betere methode?<\/P><\/BODY><\/HTML>
head, <\/SPAN>sep<\/SPAN>, <\/SPAN>tail = arcpy.Describe(parcelFabricLayer).Path.partition(".gdb"<\/SPAN>)workspacePath = head + sep<\/SPAN><\/PRE>uitleg:<\/P>Describe().Path retourneert het volledige pad dat ook de string ".gdb" bevat<\/P>partition scheidt dit met behulp van de opgegeven ".gdb" <\/SPAN>string om:<\/P>head - vóór de ".gdb" string<\/SPAN><\/LI>sep - de ".gdb" string<\/SPAN><\/LI>tail - na de ".gdb" string<\/SPAN><\/LI><\/UL><\/P>Iemand een betere methode?<\/P><\/BODY><\/HTML>
For Julian's path example I'd normally use os.
a = r"D:\Data\GISData\data\received\Transport.gdb\Routing\AccessRoad" os.path.dirname(os.path.dirname(a)) 'D:\\Data\\GISData\\data\\received\\Transport.gdb'
In Pro you can use the following:
layer.connectionProperties["connection_info"]["database"]
Hi Amir.
I do mine a little different. I don't use arcpy to get my workspace path. I find mine takes a lot quicker as it does not have to call arcpy every time, saving a few seconds. With this method you can also use any geodatabase type (.sde, .gdb or .mdb).
accessRoadFc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"D:\Data\GISData\data\received\Transport.gdb\Routing\AccessRoad"</SPAN> wkspSplit <SPAN class="operator token">=</SPAN> accessRoadFc<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"."</SPAN><SPAN class="punctuation token">)</SPAN> wkspExt <SPAN class="operator token">=</SPAN> wkspSplit<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"\\"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{}.{}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>wkspSplit<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> wkspExt<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.