Difference between revisions of "Jeemin Sim (Work Log)"

From edegan.com
Jump to navigation Jump to search
Line 355: Line 355:
 
*** License needs to be purchasesd: http://www.esri.com/software/arcgis/extensions/production-mapping/pricing
 
*** License needs to be purchasesd: http://www.esri.com/software/arcgis/extensions/production-mapping/pricing
 
** Use ogr2ogr from gdal package
 
** Use ogr2ogr from gdal package
 +
*** https://gis.stackexchange.com/questions/14432/migrating-geodatabase-data-into-postgis-without-esri-apps
 
*** Command: ogr2ogr -f "ESRI Shapefile" [Destination of shapefile] [path to gdb file]
 
*** Command: ogr2ogr -f "ESRI Shapefile" [Destination of shapefile] [path to gdb file]
 
*** Problem installing gdal
 
*** Problem installing gdal
  
 
[[Category:Work Log]]
 
[[Category:Work Log]]

Revision as of 11:28, 10 October 2017

2/6/2017 MONDAY 2PM-6PM

  • Set up wikiPage & remote desktop.
  • Started working on python version of web crawler. So far it successfully prints out a catchphrase/ description for one website. To be worked on. The python file can be found in: E:\McNair\Projects\Accelerators\Python WebCrawler\webcrawlerpython.py

2/8/2017 WEDNESDAY9AM-11AM

  • Attempted to come up with possible cases for locating the description of accelerators - pick up from extracting bodies of text from the about page (given that it exists)

2/13/2017 MONDAY 2PM-6PM

  • Goals (for trials): 1) Build ER Diagram 2) For each entity, get XML snippet 3) Build a parser/ripper for single file; the python parser can be found at: E:\McNair\Projects\FDA Trials\Jeemin_Project
  • Trial Data Project

2/15/2017 WEDNESDAY 9AM-11AM

  • Discussed with Catherine what to do with FDA Trial data and decided to have a dictionary with zip-codes as keys and number of trials occurred in that zipcode as values. Was still attempting to loop through the files without the code having to exist in the same directory as the XML files. Plan to write to excel via tsv, with zip-code as one column and # of occurrence as the other.

2/17/2017 FRIDAY 2PM-6PM

  • Completed code for counting the number of occurrences for each unique zipcode. (currently titled & located: E:\McNair\Projects\FDA Trials\Jeemin_Project\Jeemin_Running_File.py). It has been running for 20+min because of the comprehensive XML data files. Meanwhile started coding to create a dictionary with the keys corresponding to each unique trial ID, mapped to every other information (location, sponsors, phase, drugs ...etc.) (currently titled & located: E:\McNair\Projects\FDA Trials\Jeemin_Project\Jeemin_FDATrial_as_key_data_ripping.py).

2/20/2017 MONDAY 2PM-4:30PM

  • Continued working on Jeemin_FDATrial_as_key_data_ripping.py to find tags and place all of those information in a list. The other zipcode file did not finish executing after 2+ hours of running it - considering the possibility of splitting the record file into smaller bits, or running the processing on a faster machine.

2/22/2017 WEDNESDAY 9AM-12:30PM

  • Finished Jeemin_FDATrial_as_key_data_ripping.py (E:\McNair\Projects\FDA Trials\Jeemin_Project\Jeemin_FDATrial_as_key_data_ripping.py), which outputs to E:\McNair\Projects\FDA Trials\Jeemin_Project\general_data_ripping_output.txt; TODO: output four different tables & replace the write in the same for-loop as going through each file

2/24/2017 FRIDAY 2:30PM-6:30PM

  • Continued working on producing multiple tables - first two are done. Was working on location, as there are multiple location tags per location.

2/27/2017 MONDAY 2PM-6PM

  • Finished producing tables from Jeemin_FDATrial_as_key_data_ripping.py
  • Talked to Julia about LinkedIn data extracting - to be discussed further with Julia & Peter.
  • Started web crawler for Wikipedia - currently pulls Endowment, Academic staff, students, undergraduates, and postgraduates info found on Rice Wikipedia page. Can be found in : E:\McNair\Projects\University Patents\Jeemin_University_wikipedia_crawler.py

3/1/2017 WEDNESDAY 9AM-12PM

  • Started re-running Jeemin_FDATrial_as_key_data_ripping.py

3/3/2017 FRIDAY 2PM-5PM

  • Attempted to output sql tables

3/6/017 MONDAY 2PM-6PM

  • Installing python in a database
  • Added building Python function section to Working with PostgreSQL at the bottom of the page.
  • Ran FDA Trial data ripping again, as the text output files were wiped.
  • Plan on discussing with Julia and Meghana again about pulling universities and other relevant institutions from the Assignee List USA.
  • Talked to Sonia about pulling city, state, zipcode information, hence python was installed in a database. Will work with Sonia on Wednesday afternoon and see how best a regex function could be implemented

3/8/2017 WEDNESDAY 9AM-12PM

  • Output sql tables from finished run of Jeemin_FDATrial_as_key_data_ripping.py
  • Ran through assigneelist_USA.txt to see how many different ways UNIVERSITY could be spelled wrong. There were many.
  • Tried to logic through creating a pattern that could catch all different versions of UNIVERSITY. Discuss further on whether UNIVERSITIES and those that include UNIVERSITIES but include INC in the end should be pulled as relevant information

3/8/2017 WEDNESDAY 2PM-5PM

  • Wrote regex pattern that identifies all "university" matchings - can be found in E:\McNair\Projects\University Patents\university_pulled_from_assignee_list_USA -- is an output file
  • Talked to Sonia, but didn't come to solid conclusion on identifying whether key words associate with city or country by running a python function

3/13/2017 MONDAY 12PM-2PM

  • For University Patent Data Matching - matched SCHOOL (output: E:\McNair\Projects\University Patents\school_pulled_from_assignee_list_USA) and matched INSTITUTE(output: E:\McNair\Projects\University Patents\institute_pulled_from_assignee_list_USA).
  • University Patent Matching
  • To be worked on later: Grant XML parsing & general name matcher

3/14/2017 TUESDAY 12PM-2PM

  • Started pulling academy cases but there are too many cases to worry about, in terms of institution of interest. A document is located in E:\McNair\Projects\University Patents\academies_verify_cases.txt
  • Need Julia/Meghana to look through the hits and see which are relevant & extract pattern from there.
  • Having trouble outputting txt file without double quotes around every line.
  • Thinking that one text file should be output for all keywords instead of having one each, to avoid overlap (ex) COLLEGE and UNIVERSITY are both keywords; ALBERT EINSTEIN COLLEGE OF YESHIVA UNIVERSITY will be hit twice if it were counted as two separate instances, one accounting for COLLEGE and the other for UNIVERSITY) - either in the form of if-elseif statements or one big regex check.

3/15/2017 WEDNESDAY 9AM-1PM

  • Todo: write a wikipage on possible input/output info on string matcher
  • Wrote part of XML parser, extracted yearly data into E:\McNair\Projects\Federal Grant Data\NSF\NSF Extracted Data (up to year 2010)

3/16/2017 THURSDAY 12PM-2PM

3/20/2017 MONDAY 2PM-6PM

  • Talked to Julia about universal matcher, want to combine all University of California's to University of California, The Regents of
  • Converted crunchbase2013 data from mySQL to PostgreSQL, but having trouble with the last table - cb_relationships, complains about syntax error at or near some places - but generally all tables exist in database called crunchbase
  • Federal Grant Data XML Parser was run - the three output textfiles can be found in E:\McNair\Projects\Federal Grant Data\NSF

3/22/2017 WEDNESDAY 9AM-12PM

  • Read string matching & calculating distance, below are relevant links
  • [1]
  • [2]

3/24/2017 FRIDAY 2PM-5PM

  • Discussed with Julia & Meghana about university keys to use to count # of occurrences, including aliases and misspellings
  • Thoughts: to use a scoring metric with a key of UNIVERSITY OF CALIFORNIA SYSTEM, it should have a 'better' score when compared to MATHEMATICAL SCIENCES PUBLISHERS C/O UNIVERSITY OF CALIFORNIA BERKELEY or CALIFORNIA AT LOS ANGELES, UNVIERSITY OF than when compared to UNIVERSITY OF SOUTHERN CALIFORNIA, which may pose a challenge when attempting to implement this in a more general sense. In normalizing a string, strip "THE", "," and split words by spaces and compare each keyword from the two strings. Deciding on which strings to compare will be another issue - length (within some range maybe) could be an option.
  • Federal Grant Data XML Parser was rerun - same output textfiles

3/27/2017 MONDAY 2PM-6PM

  • Writing code for university matches - decided to go through keys instead of each dataitem. Use keywords in each key to go through the dataitem - misspellings are currently unaccounted for.

3/29/2017 WEDNESDAY2PM-5PM

  • Troubled by the variety of cases - separating keys by keywords will not work favorably when it hits University of California vs. University of Southern California case - find a way to match University of Southern California first (more specific ones first) - but how to generalize

. . .

4/12/2017 WEDNESDAY9AM-12PM

  • Finishing up cleaning the columns for Federal Grant Data - NIH. The output excel files can be accessed at:
E:\McNair\Projects\Federal Grant Data\NIH\Grants 
Titled:
    Jeemin_combined_files 1986-2001.csv
    Jeemin_combined_files 2002-2012.csv
    Jeemin_combined_files 2013-2015.csv
  • psql table formula:
CREATE TABLE all_grants (
 APPLICATION_ID integer,
 ACTIVITY varchar(3),
 ADMINISTERING_IC varchar(2),
 APPLICATION_TYPE varchar(1),
 ARRA_FUNDED varchar(1),
 AWARD_NOTICE_DATE date, 
 BUDGET_START date,
 BUDGET_END date, 
 CFDA_CODE varchar(3), 
 CORE_PROJECT_NUM varchar(11),
 ED_INST_TYPE varchar(30), 
 FOA_NUMBER varchar(13),
 FULL_PROJECT_NUM varchar(35),
 FUNDING_ICs varchar(40),
 FUNDING_MECHANISM varchar(23),
 FY smallint, 
 IC_NAME varchar(77), 
 NIH_SPENDING_CATS varchar(295), 
 ORG_CITY varchar(20),
 ORG_COUNTRY varchar(16),
 ORG_DEPT varchar(30),
 ORG_DISTRICT smallint, 
 ORG_DUNS integer,
 ORG_FIPS varchar(2), 
 ORG_NAME varchar(60), 
 ORG_STATE varchar(2), 
 ORG_ZIPCODE integer, 
 PHR varchar(200), 
 PI_IDS varchar(30), 
 PI_NAMEs varchar(200), 
 PROGRAM_OFFICER_NAME varchar(36), 
 PROJECT_START date, 
 PROJECT_END date, 
 PROJECT_TERMS varchar(200), 
 PROJECT_TITLE varchar(244), 
 SERIAL_NUMBER smallint,
 STUDY_SECTION varchar(4), 
 STUDY_SECTION_NAME varchar(100), 
 SUBPROJECT_ID smallint, 
 SUFFIX varchar(2),
 SUPPORT_YEAR smallint, 
 DIRECT_COST_AMT integer, 
 INDIRECT_COST_AMT integer, 
 TOTAL_COST integer, 
 TOTAL_COST_SUB_PROJECT integer
);
\COPY all_grants FROM 'Jeemin_combined_files 1986-2001.csv' WITH DELIMITER AS E'\t' HEADER NULL AS CSV

4/14/2017 FRIDAY2PM-5PM

  • Loaded Federal Grants Data into database

4/17/2017 MONDAY2PM-4PM

4/17/2017 WEDNESDAY9AM-12PM

  • To pull accelerators: Wrote simple python regex-based script that ran on organizations data.
Code: E:\McNair\Projects\Accelerators\Crunchbase Snapshot\accelerator keywords.py
Matched output (885 mathces) : E:\McNair\Projects\Accelerators\Crunchbase Snapshot\Jeemin_885_accel_matches

9/11/2017 MONDAY4PM-6PM

  • Ensured that documentation exists for the projects worked on last semester.

9/12/2017 TUESDAY9AM-10:40AM & 1PM-2:20PM & 4PM-5:30PM

  • Clarified University Matching output file.
  • Helped Christy with pdf-reader, capturing keywords in readable format.

..

9/18/2017 MONDAY4PM-6PM

9/19/2017 TUESDAY9AM-10:40AM & 1PM-2:20PM

  • Useful functions for spatial joins:
sum(expression): aggregate to return a sum for a set of records
count(expression): aggregate to return the size of a set of records
ST_Area(geometry) returns the area of the polygons
ST_AsText(geometry) returns WKT text
ST_Buffer(geometry, distance): For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper.
ST_Contains(geometry A, geometry B) returns the true if geometry A contains geometry B
ST_Distance(geometry A, geometry B) returns the minimum distance between geometry A and geometry B
ST_DWithin(geometry A, geometry B, radius) returns the true if geometry A is radius distance or less from geometry B
ST_GeomFromText(text) returns geometry
ST_Intersection(geometry A, geometry B): Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84
ST_Intersects(geometry A, geometry B) returns the true if geometry A intersects geometry B
ST_Length(linestring) returns the length of the linestring
ST_Touches(geometry A, geometry B) returns the true if the boundary of geometry A touches geometry B
ST_Within(geometry A, geometry B) returns the true if geometry A is within geometry B
geometry_a && geometry_b: Returns TRUE if A’s bounding box overlaps B’s.
geometry_a = geometry_b: Returns TRUE if A’s bounding box is the same as B’s.
ST_SetSRID(geometry, srid): Sets the SRID on a geometry to a particular integer value.
ST_SRID(geometry): Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.
ST_Transform(geometry, srid): Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.
ST_Union(): Returns a geometry that represents the point set union of the Geometries.
substring(string [from int] [for int]): PostgreSQL string function to extract substring matching SQL regular expression.
ST_Relate(geometry A, geometry B): Returns a text string representing the DE9IM relationship between the geometries.
ST_GeoHash(geometry A): Returns a text string representing the GeoHash of the bounds of the object.
  • Native functions for geogrphy:
ST_AsText(geography) returns text
ST_GeographyFromText(text) returns geography
ST_AsBinary(geography) returns bytea
ST_GeogFromWKB(bytea) returns geography
ST_AsSVG(geography) returns text
ST_AsGML(geography) returns text
ST_AsKML(geography) returns text
ST_AsGeoJson(geography) returns text
ST_Distance(geography, geography) returns double
ST_DWithin(geography, geography, float8) returns boolean
ST_Area(geography) returns double
ST_Length(geography) returns double
ST_Covers(geography, geography) returns boolean
ST_CoveredBy(geography, geography) returns boolean
ST_Intersects(geography, geography) returns boolean
ST_Buffer(geography, float8) returns geography [1]
ST_Intersection(geography, geography) returns geography [1]

9/20/2017 WEDNESDAY3:50PM-5:20PM

  • Attended first intro to GIS course yesterday
  • Updated above notes on GIS
  • Continue reading from:

9/21/2017 THURSDAY9AM-12:30PM

  • Functions for Linear Referencing:
ST_LineInterpolatePoint(geometry A, double measure): Returns a point interpolated along a line.
ST_LineLocatePoint(geometry A, geometry B): Returns a float between 0 and 1 representing the location of the closest point on LineString to the given Point.
ST_Line_Substring(geometry A, double from, double to): Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length.
ST_Locate_Along_Measure(geometry A, double measure): Return a derived geometry collection value with elements that match the specified measure.
ST_Locate_Between_Measures(geometry A, double from, double to): Return a derived geometry collection value with elements that match the specified range of measures inclusively.
ST_AddMeasure(geometry A, double from, double to): Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added.
  • 3-D Functions:
ST_3DClosestPoint — Returns the 3-dimensional point on g1 that is closest to g2. This is the first point of the 3D shortest line.
ST_3DDistance — For geometry type Returns the 3-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units.
ST_3DDWithin — For 3d (z) geometry type Returns true if two geometries 3d distance is within number of units.
ST_3DDFullyWithin — Returns true if all of the 3D geometries are within the specified distance of one another.
ST_3DIntersects — Returns TRUE if the Geometries “spatially intersect” in 3d - only for points and linestrings
ST_3DLongestLine — Returns the 3-dimensional longest line between two geometries
ST_3DMaxDistance — For geometry type Returns the 3-dimensional cartesian maximum distance (based on spatial ref) between two geometries in projected units.
ST_3DShortestLine — Returns the 3-dimensional shortest line between two geometries
  • Relevant PostgreSQL Commands:
\dt *.* Show all tables
\q Exit table
  • Specifities/ Outliers to consider:
New York (decompose)
Princeton area (keep Princeton  unique)
Reston, Virginia (keep)
San Diego (include La Jolla)
Silicon Valley (all distinct)

9/25/2017 MONDAY4PM-6PM

  • Talked to Ed about GIS, Census data, and going about determining the correctness of reported 'place.' Currently script makes a cross product of each reported place and an existing place, outputting a column of boolean value to indicate whether the reported place's coordinates fell within a place's geometric boundaries. One other way of going about this which we discussed is to first check if the reported place does fall within that place's boundaries. If it isn't, we'll go about the cross product method.
  • Discussed the need to maintain venture capital database.
  • Relevant File paths:
    • E:\McNair\Projects\Agglomeration\TestGIS.sql
    • Z:\VentureCapitalData\SDCVCData\vcdb2\ProecssingCoLevelSimple.sql
    • Z:\VentureCapitalData\SDCVCData\vcdb2\CitiesWithGT10Active.txt

9/26/2017 TUESDAY 9AM-12PM

. . .

10/2/2017 MONDAY 4PM-6PM

10/3/2017 TUESDAY 10AM-12PM & 1PM-2:30PM

  • Installed PostGIS & is now visible on pgAdmin III
  • ArcGIS (connect to postgis database):
    • 1) Open ArcMap
    • 2) Either open blank or open existing file/project
    • 3) Click on 'Add Data' button with a cross and a yellow diamond (under Selection toolbar)
    • 4) Go to the top-most directory by pressing on the arrow that points left-then-up (on the left of home button)
    • 5) Click on 'Database Connections'
    • 6) Click on 'Add Database Connection' (if Connection to localhost.sde) does not exist already)
    • 7) Fill in the following fields:
      • Database Platform: PostgreSQL
      • Instance: localhost
      • User name: postgres
      • Password:
      • Database: tigertest
    • 8) Press 'OK'
    • 9) Now you'll have 'Connection to localhost.sde' in your Database Connections
    • 10) Double click on 'Connection to localhost.sde'
    • 11) Double click on the table of interest
    • 12) Click 'Finish'
    • 13) You'll see information populated on map, as one of the 'Layers'
      • Tested with: tigertest.public.copointplacescontains
  • On running & altering Oliver's script:
    • Location: E:\McNair\Projects\OliverLovesCircles\src\python\vc_circles.py
    • Ed manipulated file names so that underscores would replace dots (St.Louis --> St_Louis)
    • Takes in instances and sweep times as part of the argument, but not impactful as those variables are hardcoded in the script
    • Ran vc_circles.py with the following variables with changed values:
      • SWEEP_CYCLE_SECONDS = 10 (used to be 30)
      • NUMBER_INSTANCES = 16 (used to be 8)
    • New output to be found in: E:\McNair\Projects\OliverLovesCircles\out

10/9/2017 MONDAY3PM-6PM

 tl_2017_us_coastline -- 4209
 tl_2017_us_primaryroads -- 11574 
 tl_2017_us_rails -- 176237

10/10/2017 TUESDAY9AM-12PM