GithubHelp home page GithubHelp logo

Comments (5)

kiauho avatar kiauho commented on July 26, 2024 1

@wchatx I try FME 2020.1 Beta. Pip was able to bring in directaccess in the new version of the software. Thanks for your help.

from direct-access-py.

wchatx avatar wchatx commented on July 26, 2024

Hi @kiauho, thanks for the question and that's a really cool use case!

I've just run through this successfully in FME Desktop 2019.2. My preferred Python interpreter is set to Python 3.7+ in the Translation options. My system has multiple versions of FME Desktop so this is the command I ran:

& "C:\Program Files\FME2019\fme.exe" python -m pip install directaccess --target C:\Users\<your.user>\Documents\FME\Plugins\Python\python37

Are you providing the --target flag? This Safe Software doc might be helpful if you haven't already seen it.

from direct-access-py.

wchatx avatar wchatx commented on July 26, 2024

Your use case was interesting to me so I put together a basic PythonCreator using this module

import fme
import fmeobjects
from directaccess import DirectAccessV2


class EnverusFeatureCreator(object):
    def __init__(self):
        self.dataset = fme.macroValues['DATASET']
        self.query = fme.macroValues['QUERY']
        self.client_id = fme.macroValues['CLIENT_ID']
        self.client_secret = fme.macroValues['CLIENT_SECRET']
        self.api_key = fme.macroValues['API_KEY']
        self.client = DirectAccessV2(self.client_id, self.client_secret, self.api_key)
        
        self.log = fmeobjects.FMELogFile()
        self.log.logMessageString(self.dataset)
        
    def input(self, feature):
        for row in self.client.query(self.dataset, **{x.split('=')[0]: x.split('=')[1] for x in self.query.split(';')}):
            f = fmeobjects.FMEFeature()
            f.setCoordSys('EPSG:4326')
            
            if row['SurfaceLongitudeWGS84'] and row['SurfaceLatitudeWGS84']:
                f.addCoordinate(row['SurfaceLongitudeWGS84'], row['SurfaceLatitudeWGS84'])
                
            for k, v in row.items():
                f.setAttribute(k, v)
            
            self.pyoutput(f)
        
    def close(self):
        pass

I created five published parameters (DATASET, QUERY, CLIENT_ID, CLIENT_SECRET, API_KEY). DATASET matches the exact name of the dataset endpoint (in this case, permits), QUERY is a semi-colon separated string of query params (pagesize=100000;deleteddate=null) and the other three are your API credentials.

This is specific to permits, with the geometry field populated using that dataset's SurfaceLongitudeWGS84 and SurfaceLatitudeWGS84 fields. It's probably easy to make this a bit more configurable.

from direct-access-py.

kiauho avatar kiauho commented on July 26, 2024

Hi wchatx,

Thanks for the prompt response and the FME sample code for PythonCreator. I am new to FME. It'll be very helpful, but first I need to overcome the directaccess installation.

My target location is different from yours. It is pointing to One Drive and the python37 is empty. The command is stuck in exactly place as before after using the command you suggested:


Collecting unicodecsv==0.14.1 (from directaccess)
Using cached https://files.pythonhosted.org/packages/6f/a4/691ab63b17505a26096608cc309960b5a6bdf39e4ba1a793d5f9b1a53270/unicodecsv-0.14.1.tar.gz
Error [WinError 2] The system cannot find the file specified while executing command python setup.py egg_info
Could not install packages due to an EnvironmentError: [WinError 2] The system cannot find the file specified

Any new thoughts?

Thanks in advance.

Kiauho

from direct-access-py.

wchatx avatar wchatx commented on July 26, 2024

@kiauho try removing the \python37, I should not have included that. This module is usable in Python versions 2.7 and all of 3.x, hence Safe says your target should be C:\Users\<user>\Documents\FME\Plugins\Python in their docs (modified for your unique situation).

I'm surprised to hear that your target deviates from what Safe specifies and that it's on a network-synced directory. That very well could be the source of your problem and I don't think I'll have much to offer there.

You can also try these older instructions using ez_setup.

Please follow up with your progress! I recall having installed modules into FME's python in a more traditional way previously and can try stepping through that if all else fails.

from direct-access-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.